package org.example.v5.example.action;

import org.example.v5.example.enums.OrderEvent;
import org.example.v5.example.enums.OrderStateAction;
import org.example.v5.statemachine.AbstractStateAction;
import org.example.v5.statemachine.StateMachine;

public class PendingOrderStateAction extends AbstractStateAction<StateMachine<OrderStateAction, OrderEvent>, OrderEvent> {
    @Override
    protected boolean isValidEvent(OrderEvent event) {
        return event == OrderEvent.PAY;
    }

    @Override
    protected void nextState(StateMachine<OrderStateAction, OrderEvent> context, OrderEvent event) {
        context.setStateAction(new PaidOrderStateAction());
    }

    @Override
    protected void handleInternal(StateMachine<OrderStateAction, OrderEvent> context, OrderEvent event) {
        LOGGER.info("支付订单逻辑执行");
    }
}